package org.mixed.script;

import java.lang.invoke.*;
import java.lang.invoke.MethodHandles.Lookup;

import static java.lang.invoke.MethodHandles.lookup;

public class FunctionCallHandle {

//    static {
//        lookup()
//    }

    public static CallSite bootstrap(Lookup lookup, String name, MethodType type) {
        MutableCallSite callSite = new MutableCallSite(type);
        try {
            MethodHandle methodHandle = lookup.findVirtual(FunctionCallHandle.class, name, type);
            callSite.setTarget(methodHandle);
            return callSite;
        } catch (NoSuchMethodException | IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    }
}
